package com.huilian.iotbox.admin.wap.controller;

import com.huilian.iotbox.admin.wap.service.LedgerMerchantRecordService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.LedgerMerchantRecordDto;
import com.huilian.iotbox.data.vo.UserInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/ledgerMerchantRecord")
public class LedgerMerchantRecordController extends UserInfoController{
    @Resource
    private LedgerMerchantRecordService ledgerMerchantRecordService;

    /**
     * 操作单个场地分账
     * */
    @PostMapping("/editLedgerMerchantOrRecord")
    private ServerResponse editLedgerMerchantOrRecord(@RequestBody LedgerMerchantRecordDto ledgerMerchantRecordDto, HttpServletRequest request){
        UserInfo userInfo = super.getLoginUserInfo(request);
        ledgerMerchantRecordDto.setUserInfo(userInfo);
       return ledgerMerchantRecordService.editLedgerMerchantOrRecord(ledgerMerchantRecordDto);
    }

    /**
     * 批量操作场地分账
     * */
    @PostMapping("/editLedgerMerchantOrRecordBatch")
    private ServerResponse editLedgerMerchantOrRecordBatch(@RequestBody LedgerMerchantRecordDto ledgerMerchantRecordDto, HttpServletRequest request){
        UserInfo userInfo = super.getLoginUserInfo(request);
        ledgerMerchantRecordDto.setUserInfo(userInfo);
        ledgerMerchantRecordDto.setUserId(userInfo.getId());
        return ledgerMerchantRecordService.editLedgerMerchantOrRecordBatch(ledgerMerchantRecordDto);
    }


}
